﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Mocola.BLL;
using Mocola.Model;
using Mocola.Web;
using Mocola.Common;
using Mocola.Security;
using System.Web.Security;
using System.Data.Common;

namespace Mocola.Net.Web
{
    public partial class changepwd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnXiuGai_Click(object sender, EventArgs e)
        {
            MD5Verifier md5 = new MD5Verifier();

            if (MocolaUser.CurrentUser.UserPwd == md5.getMd5Hash(txtJiuMiMa.Text.Trim()))
            {
                Databases.MocolaNet.Update(Moc_UsersInfo.Moc_Users)
                    .AddColumn(Moc_UsersInfo.Moc_Users.UserPwd, md5.getMd5Hash(txtXinMiMa.Text.Trim()))
                    .Where(Moc_UsersInfo.Moc_Users.UserID == MocolaUser.CurrentUser.UserID)
                    .Execute();
                Alert.Show("修改成功!请重新登陆!");
            }
            else
            {
                Alert.Show("旧密码错误!");
            }
        }
    }
}
